package com.zi.experttalk.experttalk.Model.service;

import android.content.Context;
import android.util.Log;
import com.baidu.location.BDLocation;
import com.baidu.location.BDLocationListener;
import com.baidu.location.LocationClient;
import com.baidu.location.LocationClientOption;

/**
 * Created by Administrator on 2014/12/17.
 */
public class LocationManager {
    private LocationClient locationClient;
    private BDLocationListener bdLocationListener;
    public void getAdd(Context context){
        locationClient = new LocationClient(context);
        bdLocationListener = new MyBDLocationListener();
        locationClient.registerLocationListener(bdLocationListener);
        InitLocation();
        locationClient.start();
        locationClient.requestLocation();
    }

    //初始化定位
    public void InitLocation(){
        LocationClientOption option = new LocationClientOption();
        //定位精度
        option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy);
        //定位类型
        option.setCoorType("gcj02");
        //是否反编译
        option.setIsNeedAddress(true);
        locationClient.setLocOption(option);
        Log.d("--11","初始化");
    }
    //监听事件
    public class MyBDLocationListener implements BDLocationListener {

        @Override
        public void onReceiveLocation(BDLocation bdLocation) {
            Log.d("--11",bdLocation.getAddrStr());
        }
    }
}
